<div class="judul"><?php echo anchor("/info_log_adik_asuh/", $title);?></div>
<?php
 $uri_segment = $this->uri->segment(3);
 if($uri_segment != "" && $uri_segment != "all"){
    $option = parsing_param2($uri_segment);
    $awal = datefmysql($option['awal']);
    $akhir = datefmysql($option['akhir']);
    $adikAsuh = $option['AdikAsuh'];
    $idAdikAsuh = $option['idAdikAsuh'];
    $idTahunAjaran = $option['idTahunAjaran'];
 }else{
     $awal = date('d/m/Y');
     $akhir = date('d/m/Y');
     $adikAsuh = '';
     $idAdikAsuh = '';
     $idTahunAjaran = '';
 }
?>
<script type="text/javascript">
  $(function() {
        $('#adik_asuh').autocomplete("<?php echo site_url('ajax_target/searchAdikAsuh');?>",
        {
            parse: function(data){
                var parsed = [];
                for (var i=0; i < data.length; i++) {
                    parsed[i] = {
                        data: data[i],
                        value: data[i].nama // nama field yang dicari
                    };
                }
                return parsed;
            },
            formatItem: function(data,i,max){
                var str='<div class=result>'+data.nama+'<br />Alamat: '+data.alamat+'<br />Sekolah: '+data.sekolah+'</div>';
                return str;
            },
            width: 270, // panjang tampilan pencarian autocomplete yang akan muncul di bawah textbox pencarian
            dataType: 'json' // tipe data yang diterima oleh library ini disetup sebagai JSON
        }).result(
            function(event,data,formated){
                $(this).val(data.nama);
                $('#id_adik_asuh').val(data.id);
            });
   })         
</script>
<div class="data-input">
    <fieldset>
        <legend><?php echo "$formTitle";?></legend>
        <?php
          echo form_open("info_log_adik_asuh/search");
        ?>
        <fieldset class="field-group">
            <legend>Tanggal Input Log</legend>
            <?php echo form_input("awal", $awal, "id='awal' class='tanggal datepicker-input'")?>
            <label class="inline-title">s.d</label>
            <?php echo form_input("akhir", $akhir, "id='akhir' class='tanggal datepicker-input'")?>
        </fieldset>
        <label>Adik asuh</label>
        <?php echo form_input("adik_asuh", $adikAsuh, "id='adik_asuh'");?>
        <input type="hidden" name="id_adik_asuh" id="id_adik_asuh" value="<?php echo "$idAdikAsuh";?>" />
        <label>Tahun Ajaran</label>
        <select name="tahun_ajaran">
            <option value="">Pilih tahun ajaran</option>
            <?php
              foreach($listTahunAjaran as $row){
            ?>
            <option value="<?php echo $row['id'];?>" <?php if($row['id'] == $option['idTahunAjaran']) echo 'selected=selected'?>><?php echo $row['nama'].' '.$row['semester'];?></option>
            <?
              }
            ?>
        </select>
        <fieldset class="input-process">
            <?php
              echo form_hidden("url", $searchLink);
              echo form_submit('add', 'Cari', 'class=button style=margin-right:2px');
              echo form_button('Batal', 'Batal', 'class=button onClick='."javascript:location.href='".base_url()."index.php/info_log_adik_asuh/'".'');
            ?>
        </fieldset>
        <?php
          echo form_close();
        ?>
    </fieldset>
</div>
<fieldset>
<?php
  if($uri_segment == ''){
      echo "<span class='tips'>Silahkan menggunakan opsi pencarian di atas</span>";
  }else{
?>     
<div class="data-list">
    <div style="float: right">
        <span class="cetak" onclick="window.open('<?php echo base_url()."index.php/info_log_adik_asuh/print_log_adik_asuh/$uri_segment"?>', 'mywindow', 'width=1000','height=850')">cetak</span>
        <a class="excel" href="<?php echo site_url('info_log_adik_asuh/export_data').'/'.$uri_segment?>">cetak</a>
    </div>
    <table class="tabel" style="width: 100%">
        <tr>
            <th>No</th>
            <th>Tanggal</th>
            <th>Petugas</th>
            <th>Adik Asuh</th>
            <th>Sekolah</th>
            <th>Kelas</th>
            <th>Tahun Ajaran</th>
            <th>Komentar</th>
        </tr>
        <?php
            $offsets = isset ($offset)?$offset:0;
            $no = 1 + $offsets;
            foreach ($listLogAdikAsuh as $rows){
        ?>
        <tr class="<?php echo ($no%2)?"even":"odd";?>">
            <td style="text-align: center;width: 3%;"><?php echo $no++;?></td>
            <td style="width: 10%"><?php echo datefmysql($rows['tanggal']);?></td>
            <td style="width: 15%"><?php echo $rows['member'];?></td>
            <td style="width: 15%"><?php echo $rows['adik_asuh'];?></td>
            <td style="width: 20%"><?php echo $rows['sekolah'];?></td>
            <td style="width: 5%"><?php echo $rows['kelas'];?></td>
            <td style="width: 10%"><?php echo $rows['tahun_ajaran']." ".$rows['semester'];?></td>
            <td style="text-align: justify"><?php echo $rows['komentar'];?></td>
        </tr>
        <?php
            }
        ?>
    </table>
</div>
<?php
  echo "$pagination";
  }
?>
</fieldset>